﻿<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    [DirectMethod]
    public void OnCustomerComboTriggerClick()
    {
        X.AddScript("CustomerListStore.reload()");
    }
    
    
    
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
    <title>送货单列表</title>
    <script type="text/javascript" src="/Scripts/Commen.js"></script>
    <script type="text/javascript" src="/Scripts/INV_SendOrder/INV_OrderList.js"></script>
    <script type="text/javascript">
        var prepareEditDel = function (grid, toolbar, rowIndex, record) {
            var editButton = toolbar.items.get(1);
            var delButton = toolbar.items.get(2);
            if (record.data.FStatus == "已审核") {
                editButton.setDisabled(true);
                editButton.setTooltip("不可用");
            }
            if (record.data.FStatus == "已删除") {
                editButton.setDisabled(true);
                editButton.setTooltip("不可用");
                delButton.setDisabled(true);
                delButton.setTooltip("不可用");
            }
        };

        var changeSortDirect = function () {
            if (SortDirect.Value == "desc" || SortDirect.Value == "") {
                SortDirect.Value = "asc";
            }
            else {
                SortDirect.Value = "desc";
            }
        };
    </script>
</head>
<body>
    <script type="text/javascript" src="/Scripts/ExtTimeOut.js"></script>
    <script type="text/javascript" src="/Scripts/ExtRequiredFieldPluins.js"></script>
    <%--<form id="Form1" runat="server">--%>
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <!-- 选择的送货单编号 -->
    <ext:Hidden ID="SelectOrderFIdH" IDMode="Explicit" runat="server" Text="" AutoDataBind="true">
    </ext:Hidden>
    <!-- 编辑的送货单编号 -->
    <ext:Hidden ID="EditOrderFIdH" IDMode="Explicit" runat="server" Text="" AutoDataBind="true">
    </ext:Hidden>
    <!-- 选择的送货单详情编号 -->
    <ext:Hidden ID="SelectOrderDetailFIdH" IDMode="Explicit" runat="server" Text="" AutoDataBind="true">
    </ext:Hidden>
    <!-- 编辑的送货单详情编号 -->
    <ext:Hidden ID="EditOrderDetailFIdH" IDMode="Explicit" runat="server" Text="" AutoDataBind="true">
    </ext:Hidden>
    <ext:Hidden ID="SortDirect" IDMode="Explicit" runat="server" Text="" AutoDataBind="true" />
    <ext:Hidden ID="OrderStatus" IDMode="Explicit" runat="server" Text="" AutoDataBind="true" />
    <!-- 送货单列表数据源 -->
    <ext:Store ID="OrderListStore" IDMode="Explicit" runat="server" RemoteSort="true"
        SkipIdForNewRecords="false" UseIdConfirmation="false" SerializationMode="Complex">
        <Proxy>
            <ext:HttpProxy Url="/SendOrder/getOrderList/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FNumber" />
                    <ext:RecordField Name="FName" />
                    <ext:RecordField Name="FCustomer" />
                    <ext:RecordField Name="FBillDate" />
                    <ext:RecordField Name="FCreateTime" />
                    <ext:RecordField Name="FCreator" />
                    <ext:RecordField Name="FModifyTime" />
                    <ext:RecordField Name="FModifier" />
                    <ext:RecordField Name="FApproveTime" />
                    <ext:RecordField Name="FApprover" />
                    <ext:RecordField Name="FRemark" />
                    <ext:RecordField Name="FStatus" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="FStartDate" Value="#{dfStartDate}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FEndDate" Value="#{dfEndDate}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FCustomerID" Value="#{tfCustomerName}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FOrderNumber" Value="#{tfOrderNumber}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FStatusId" Value="#{ComboOrderStatus}.getValue()" Mode="Raw" />
        </BaseParams>
        <SortInfo Field="FId" Direction="DESC" />
    </ext:Store>
    <!-- 送货单明细列表数据源 -->
    <ext:Store ID="OrderDetailListStore" IDMode="Explicit" runat="server" RemoteSort="false"
        SkipIdForNewRecords="false" UseIdConfirmation="false" SerializationMode="Complex">
        <Proxy>
            <ext:HttpProxy Url="/SendOrder/getOrderDetailList/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FParentId" />
                    <ext:RecordField Name="FProductId" />
                    <ext:RecordField Name="FProductNumber" />
                    <ext:RecordField Name="FProductName" />
                    <ext:RecordField Name="FQty" />
                    <ext:RecordField Name="FNumber" />
                    <ext:RecordField Name="FPrice" />
                    <ext:RecordField Name="FAmount" />
                    <ext:RecordField Name="FRemark" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="FParentId" Value="#{SelectOrderFIdH}.getValue()" Mode="Raw" />
        </BaseParams>
        <SortInfo Field="FProductNumber" Direction="ASC" />
    </ext:Store>
    <!-- 编辑送货单数据源 -->
    <ext:Store ID="EditOrderStore" runat="server" AutoLoad="false">
        <Proxy>
            <ext:HttpProxy Url="/SendOrder/getOrder/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FNumber" />
                    <ext:RecordField Name="FName" />
                    <ext:RecordField Name="FCustomer" />
                    <ext:RecordField Name="FCustomerId" />
                    <ext:RecordField Name="FBillDate" />
                    <ext:RecordField Name="FCreateTime" />
                    <ext:RecordField Name="FCreator" />
                    <ext:RecordField Name="FModifyTime" />
                    <ext:RecordField Name="FModifier" />
                    <ext:RecordField Name="FApproveTime" />
                    <ext:RecordField Name="FApprover" />
                    <ext:RecordField Name="FRemark" />
                    <ext:RecordField Name="FStatus" />
                    <ext:RecordField Name="FStatusId" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="FId" Value="#{EditOrderFIdH}.getValue()" Mode="Raw" />
        </BaseParams>
        <Listeners>
            <BeforeLoad Handler="#{EditOrderFormPanel}.el.mask('正在加载信息...', 'x-mask-loading');" />
            <LoadException Handler="#{EditOrderFormPanel}.el.unmask();" />
            <Load Fn="INV_OrderList.Mgr.formStoreLoaded" />
        </Listeners>
    </ext:Store>
    <!-- 编辑送货单详情数据源 -->
    <%--<ext:Store ID="EditOrderDetailStore" runat="server" AutoLoad="false">
        <Proxy>
            <ext:HttpProxy Url="/SendOrder/getOrderDetail/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FParentId" />
                    <ext:RecordField Name="FProductId" />
                    <ext:RecordField Name="FProductName" />
                    <ext:RecordField Name="FQty" />
                    <ext:RecordField Name="FNumber" />
                    <ext:RecordField Name="FPrice" />
                    <ext:RecordField Name="FAmount" />
                    <ext:RecordField Name="FRemark" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="FId" Value="#{EditOrderDetailFIdH}.getValue()" Mode="Raw" />
        </BaseParams>
        <Listeners>
            <BeforeLoad Handler="#{EditOrderDetailFormPanel}.el.mask('正在加载信息...', 'x-mask-loading');" />
            <LoadException Handler="#{EditOrderDetailFormPanel}.el.unmask();" />
            <Load Fn="INV_OrderList.Mgr.formStoreLoaded" />
        </Listeners>
    </ext:Store>--%>
    <!-- 客户数据源 -->
    <ext:Store ID="CustomerListStore" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/SendOrder/getCustomerList/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <!-- 状态数据源 -->
    <ext:Store ID="OrderStatusListStore" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/SendOrder/getSendOrderStatusList/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FID" />
                    <ext:RecordField Name="FName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="OrderStatusListForSaveStore" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/SendOrder/getSendOrderStatusListForSave/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FID" />
                    <ext:RecordField Name="FName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" Layout="border">
        <Items>
            <%--<ext:Panel ID="Panel1" runat="server" Title="编辑" Region="North"
                Split="true" Collapsible="true" Height="250">
                <Items>--%>
            <ext:FormPanel ID="EditOrderFormPanel" runat="server" Region="North" Split="true"
                Collapsible="true" Height="260" PaddingSummary="5px 5px 5px 5px" Border="false"
                Frame="false" AutoScroll="true" Url="/SendOrder/updateSendOrder/" Layout="BorderLayout">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                            <ext:Button ID="btPrint" runat="server" Text="导出并打印" Icon="Add">
                                <Listeners>
                                    <Click Fn="INV_OrderList.Mgr.Print" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="btSaveOrder" runat="server" Text="保存" Icon="Disk">
                                <Listeners>
                                    <Click Fn="INV_OrderList.Mgr.SaveOrder" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:FieldSet ID="EditOrderFieldSet" runat="server" CheckboxToggle="false" Title="送货单"
                        Collapsed="false" LabelWidth="80" Layout="FormLayout" LabelAlign="Right" Region="West"
                        Width="560">
                        <Items>
                            <ext:Container ID="Container1" runat="server" Layout="HBoxLayout" Height="30">
                                <Items>
                                    <ext:TextField ID="FNumber" runat="server" FieldLabel="订单号" Width="270" Disabled="true" />
                                    <ext:TextField ID="FName" runat="server" FieldLabel="订单名称" Width="270" Disabled="true" />
                                </Items>
                            </ext:Container>
                            <ext:Container ID="Container2" runat="server" Layout="HBoxLayout" Height="30">
                                <Items>
                                    <ext:TextField ID="FCreateTime" runat="server" FieldLabel="创建时间" Width="270" Disabled="true" />
                                    <ext:TextField ID="FCreator" runat="server" FieldLabel="创建人" Width="270" Disabled="true" />
                                </Items>
                            </ext:Container>
                            <ext:Container ID="Container3" runat="server" Layout="HBoxLayout" Height="30">
                                <Items>
                                    <ext:TextField ID="FApproveTime" runat="server" FieldLabel="审核时间" Width="270" Disabled="true" />
                                    <ext:TextField ID="FApprover" runat="server" FieldLabel="审核人" Width="270" Disabled="true" />
                                </Items>
                            </ext:Container>
                            <ext:Container ID="Container4" runat="server" Layout="HBoxLayout" Height="30">
                                <Items>
                                    <%-- 
                                    <ext:DateField ID="FBillDate" runat="server" FieldLabel="开单日期" Width="250" AllowBlank="false"
                                        Format="yyyy/MM/dd" Disabled="true" />
                                    --%>
                                    <ext:TextField ID="FBillDate" runat="server" FieldLabel="开单时间" Width="270" Disabled="true" />
                                    <ext:TextField ID="FModifier" runat="server" FieldLabel="修改人" Width="270" Disabled="true" />
                                </Items>
                            </ext:Container>
                            <ext:Container ID="Container5" runat="server" Layout="HBoxLayout" Height="30">
                                <Items>
                                    <ext:ComboBox ID="FCustomer" runat="server" FieldLabel="客户名称" Width="270" DisplayField="FName"
                                        DataIndex="FCustomerId" ValueField="FId" StoreID="CustomerListStore">
                                        <Listeners>
                                            <BeforeRender Handler="this.onTriggerClick = this.onTriggerClick.createSequence(function () {
                                                               Ext.net.DirectMethods.OnCustomerComboTriggerClick();
                                                           });" />
                                        </Listeners>
                                    </ext:ComboBox>
                                    <ext:TextField ID="FModifyTime" runat="server" FieldLabel="修改时间" Width="270" Disabled="true" />
                                </Items>
                            </ext:Container>
                            <ext:Container ID="Container6" runat="server" Layout="HBoxLayout" Height="30">
                                <Items>
                                    <ext:TextField ID="FRemark" runat="server" FieldLabel="备注" Width="270" />
                                    <ext:ComboBox ID="FStatus" runat="server" FieldLabel="状态" Width="270" DisplayField="FName"
                                        ValueField="FID" DataIndex="FStatusId" StoreID="OrderStatusListForSaveStore"
                                        AllowBlank="false">
                                    </ext:ComboBox>
                                </Items>
                            </ext:Container>
                        </Items>
                    </ext:FieldSet>
                    <ext:Panel ID="OrderDetailListPanel" runat="server" Title="" Region="Center" Layout="AccordionLayout"
                        Split="true" Collapsible="true" Header="false">
                        <Items>
                            <ext:GridPanel ID="OrderDetailListGridPanel" runat="server" Border="false" StoreID="OrderDetailListStore"
                                TrackMouseOver="true" ClicksToEdit="0" Region="Center" AutoExpandColumn="FProductName"
                                StripeRows="true">
                                <ColumnModel ID="ColumnModel2" runat="server" DefaultSortable="false">
                                    <Columns>
                                        <ext:Column ColumnID="FProductId" DataIndex="FProductId" Header="编号" Hidden="true">
                                        </ext:Column>
                                        <ext:Column ColumnID="FProductNumber" DataIndex="FProductNumber" Header="产品编号" Width="80"
                                            Sortable="true">
                                        </ext:Column>
                                        <ext:Column ColumnID="FProductName" DataIndex="FProductName" Header="产品名称">
                                        </ext:Column>
                                        <ext:Column ColumnID="FQty" DataIndex="FQty" Header="件数" Width="60">
                                        </ext:Column>
                                        <ext:Column ColumnID="FNumber" DataIndex="FNumber" Header="数量" Width="60">
                                        </ext:Column>
                                        <ext:Column ColumnID="FPrice" DataIndex="FPrice" Header="单价" Width="60">
                                        </ext:Column>
                                        <ext:Column ColumnID="FAmount" DataIndex="FAmount" Header="总额" Width="100">
                                        </ext:Column>
                                        <ext:Column ColumnID="FRemark" DataIndex="FRemark" Header="备注" Width="60">
                                        </ext:Column>
                                        <%-- <ext:CommandColumn Width="60">
                                            <Commands>
                                                <ext:GridCommand CommandName="EditOrderDetail" Text="编辑" Icon="ApplicationEdit">
                                                </ext:GridCommand>
                                            </Commands>
                                        </ext:CommandColumn>
                                        <ext:CommandColumn Width="60">
                                            <Commands>
                                                <ext:GridCommand CommandName="DelOrderDetail" Text="删除" Icon="ApplicationDelete">
                                                </ext:GridCommand>
                                            </Commands>
                                        </ext:CommandColumn>--%>
                                    </Columns>
                                </ColumnModel>
                                <Listeners>
                                    <Command Fn="INV_OrderList.Mgr.commandHandler" />
                                    <HeaderClick Handler="if (columnIndex === 1) { changeSortDirect(); }" />
                                </Listeners>
                                <LoadMask ShowMask="true" />
                                <SelectionModel>
                                    <ext:RowSelectionModel>
                                    </ext:RowSelectionModel>
                                </SelectionModel>
                            </ext:GridPanel>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:FormPanel>
            <%--</Items>
            </ext:Panel>--%>
            <ext:FormPanel ID="SearchFormPanel" runat="server" Title="筛选条件" Region="West" Width="250"
                Split="true" Collapsible="true" Layout="FormLayout" Padding="5" LabelWidth="60">
                <Items>
                    <ext:DateField ID="dfStartDate" runat="server" FieldLabel="起始日期" Format="yyyy/MM/dd"
                        AnchorHorizontal="100%" Width="180" />
                    <ext:DateField ID="dfEndDate" runat="server" FieldLabel="结束日期" Format="yyyy/MM/dd"
                        AnchorHorizontal="100%" Width="180" />
                    <%--<ext:TextField ID="tfCustomerName" runat="server" FieldLabel="客户名称" AnchorHorizontal="100%" /> --%>
                    <ext:ComboBox ID="tfCustomerName" runat="server" FieldLabel="客户名称" DisplayField="FName"
                        ValueField="FId" StoreID="CustomerListStore" Width="175">
                        <Listeners>
                            <BeforeRender Handler="this.onTriggerClick = this.onTriggerClick.createSequence(function () {
                                                               Ext.net.DirectMethods.OnCustomerComboTriggerClick();
                                                           });" />
                        </Listeners>
                    </ext:ComboBox>
                    <ext:TextField ID="tfOrderNumber" runat="server" FieldLabel="订单号" AnchorHorizontal="100%"
                        Width="180" />
                    <ext:ComboBox ID="ComboOrderStatus" runat="server" FieldLabel="状态" Width="175" DisplayField="FName"
                        ValueField="FID" DataIndex="FStatusId" StoreID="OrderStatusListForSaveStore">
                    </ext:ComboBox>
                </Items>
                <Buttons>
                    <ext:Button ID="btSearch" runat="server" Text="搜索" Icon="Accept">
                        <Listeners>
                            <Click Fn="INV_OrderList.Mgr.Search" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btClear" runat="server" Text="清空" Icon="Cancel">
                        <Listeners>
                            <Click Fn="INV_OrderList.Mgr.Clear" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
            <ext:Panel ID="OrderListPanel" runat="server" Region="Center" Layout="AccordionLayout"
                Split="true" Collapsible="true" Header="false">
                <Items>
                    <ext:GridPanel ID="OrderListGridPanel" runat="server" Border="false" StoreID="OrderListStore"
                        Layout="FitLayout" TrackMouseOver="true" ClicksToEdit="0" Region="Center">
                        <%--<TopBar>
                            <ext:Toolbar ID="TopBar2" runat="server">
                                <Items>
                                    <ext:ToolbarFill ID="ToolbarFill2" runat="server" />
                                    <ext:Button ID="btFind" runat="server" Text="选择" Icon="Find">
                                        <Listeners>
                                            <Click Fn="INV_OrderList.Mgr.SelectOrder" />
                                        </Listeners>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>--%>
                        <ColumnModel ID="ColumnModel1" runat="server" DefaultSortable="false">
                            <Columns>
                                <ext:Column ColumnID="FId" DataIndex="FId" Header="编号" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FNumber" DataIndex="FNumber" Header="订单号" Width="130">
                                </ext:Column>
                                <ext:Column ColumnID="FName" DataIndex="FName" Header="名称" Width="130">
                                </ext:Column>
                                <ext:Column ColumnID="FCustomer" DataIndex="FCustomer" Header="客户名称">
                                </ext:Column>
                                <ext:Column ColumnID="FBillDate" DataIndex="FBillDate" Header="开单日期" Width="130">
                                </ext:Column>
                                <ext:Column ColumnID="FCreateTime" DataIndex="FCreateTime" Header="创建时间" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FCreator" DataIndex="FCreator" Header="创建人" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FModifyTime" DataIndex="FModifyTime" Header="修改时间" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FModifier" DataIndex="FModifier" Header="修改人" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FApproveTime" DataIndex="FApproveTime" Header="审核时间" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FApprover" DataIndex="FApprover" Header="审核人" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FRemark" DataIndex="FRemark" Header="备注">
                                </ext:Column>
                                <ext:Column ColumnID="FStatus" DataIndex="FStatus" Header="状态">
                                </ext:Column>
                                <ext:CommandColumn Width="180">
                                    <Commands>
                                        <ext:GridCommand CommandName="ViewOrder" Text="查看" Icon="ApplicationViewDetail">
                                        </ext:GridCommand>
                                        <ext:GridCommand CommandName="EditOrder" Text="编辑" Icon="ApplicationEdit">
                                        </ext:GridCommand>
                                        <ext:GridCommand CommandName="DelOrder" Text="删除" Icon="ApplicationDelete">
                                        </ext:GridCommand>
                                    </Commands>
                                    <PrepareToolbar Fn="prepareEditDel" />
                                </ext:CommandColumn>
                                <%-- <ext:CommandColumn Width="60">
                                    <Commands>
                                        <ext:GridCommand CommandName="SelectOrder" Text="选择" Icon="ApplicationForm">
                                        </ext:GridCommand>
                                    </Commands>
                                </ext:CommandColumn>--%>
                            </Columns>
                        </ColumnModel>
                        <BottomBar>
                            <ext:PagingToolbar ID="PagingToolbar1" runat="server" StoreID="OrderListStore" PageSize="15" />
                        </BottomBar>
                        <Listeners>
                            <Command Fn="INV_OrderList.Mgr.commandHandler" />
                        </Listeners>
                        <LoadMask ShowMask="true" />
                        <SelectionModel>
                            <ext:RowSelectionModel>
                            </ext:RowSelectionModel>
                        </SelectionModel>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    <%--</form>--%>
</body>
</html>
